package com.edgar.designpattern.observer.clock;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Subject {
    private List<Observer> observers = new ArrayList<Observer>();

    public void notifyObserver() {
        for (Iterator<Observer> iterator = observers.iterator(); iterator
                .hasNext();) {
            Observer observer = iterator.next();
            observer.update();
        }
    }

    public void registerObserver(Observer observer) {
        this.observers.add(observer);
    }
}
